//Class of clustering
#pragma once
#include <iostream>
#include <math.h>

#include "kdtree.h" //coeds form https://code.google.com/p/kdtree/
#include "DataPoint.h"
using namespace std;
 
 class ClusterAnalysis
 {
 private:
     vector<DataPoint> dataSets;			//All the points
     unsigned int dimNum;					//Point dimension
     double radius;							//Max radius to be a neighbor(eps)
     unsigned int dataNum;					//Number of points
     unsigned int minPTs;					//Mininum number of neighbor points to be a key point
	 vector<vector<int>> clusterPtsIds;		//Points IDs in each cluster
	 vector<int> currentCluster;			//Point IDs in the current expanding cluster

     void SetNeighborPoints(DataPoint& dp);                               //Set the neighborhood
     void KeyPointCluster( unsigned long i, unsigned long clusterId );    //expand clustering
public:
	kdtree* kdTree;
     ClusterAnalysis(){};
     bool Init(vector<DataPoint>& dataSets, double radius, int minPTs);    //Initialize
     bool DBSCANClustering();				//DBSCAN clustering
	 void getClusteredPointsNumber(vector<vector<int>>& results){results = clusterPtsIds;}; //get the points number of each cluster
	 void getClusteredData(vector<DataPoint>& outputDataSets){ outputDataSets = dataSets;};
};